// @ts-ignore
import { query } from '@/services/api';


const info = {
  id: '796455538121867264',
  openId: 'ooM3m1FywEm3QbAWboXePW3VpGEw',
  mobile: '15250235900',
  location: '中国-重庆-',
  nickname: 'Dave',
  headImg:
    'https://thirdwx.qlogo.cn/mmopen/vi_32/g12TBdlHrVvLhEYD3clvOMcFwYlWm9MwjjaAtJy1MpKSeibbOLOBlKL0b7jLDZHZag5ZSEPuP4YEdNl7ZRuOic9A/132',
  isNeedBind: false,
};

// localStorage.setItem('userInfo', JSON.stringify(info));
// localStorage.setItem('openId', 'ooM3m1FywEm3QbAWboXePW3VpGEw');
// localStorage.setItem('patientId', '796859356609347584');

export default {
  namespace: 'global',
  state: {
    chapterData: [],
  },
  effects: {
    *fetch({ payload }, { call, put }) {
      const response = yield call(query, payload);
      yield put({
        type: 'save',
        payload: response,
      });
    },
  },
  reducers: {
    save(state) {
      return {
        ...state,
      };
    },
  },
  subscriptions: {
    setup({ dispatch, history }) {
      return history.listen(({ pathname, query }) => {
        if (pathname === '/users') {
          dispatch({ type: 'fetch', payload: query });
        }
      });
    },
  },
};
